# include <bits/stdc++.h>
using namespace std;

inline char getc() { 
    static char buf[1 << 18], *fs, *ft;
    return (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 18, stdin)), fs == ft) ? EOF : *fs++;
}

inline int gn() { 
    int k = 0, f = 1;
    char c = getc();
    for(; !isdigit(c); c = getc()) if(c == '-') f = -1;
    for(; isdigit(c); c = getc()) k = k * 10 + c - '0';
    return k * f;
}

int l = 1, r, ans = -0x7fffffff, sum, temp = 1;

int main() { 
# ifndef LOCAL
    freopen("subq.in", "r", stdin);
    freopen("subq.out", "w", stdout);
# endif
    int n = gn();
    for(int i = 1; i <= n; i++) { 
        sum += gn();
        if(sum > ans) l = temp, r = i, ans = sum;
        if(sum < 0) temp = i + 1, sum = 0;
    }
    printf("%d\n%d\n%d\n", l, r, ans);
    return 0;
}
